function Toast(msg,duration){ duration=isNaN(duration)?3000:duration; var m = document.createElement('div'); m.innerHTML = msg; m.style.cssText="max-width:60%;min-width: 150px;padding:0 14px;height: 40px;color: rgb(255, 255, 255);line-height: 40px;text-align: center;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: rgba(0, 0, 0,.7);font-size: 16px;"; document.body.appendChild(m); setTimeout(function() { var d = 0.5; m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in'; m.style.opacity = '0'; setTimeout(function() { document.body.removeChild(m) }, d * 1000); }, duration); }



var ph =  {
	ver : '2.0.1',
	base : '' ,
	config : { requestMode : 0 }, //index.php?_url=
	
	queryString: function(key) {
		return (document.location.search.match(new RegExp("(?:^\\?|&)" + key
			+ "=(.*?)(?=&|$)")) || [ '', null ])[1];
	},
	cookie : function(name, value, options) {
		if (typeof value != 'undefined') {
			options = options || {};
			if (value === null) {
				value = '';
				options = $.extend({}, options);
				options.expires = -1;
			}
			var expires = '';
			if (options.expires
					&& (typeof options.expires == 'number' || options.expires.toUTCString)) {
				var date;
				if (typeof options.expires == 'number') {
					date = new Date();
					date.setTime(date.getTime()
							+ (options.expires * 24 * 60 * 60 * 1000));
				} else {
					date = options.expires;
				}
				expires = '; expires=' + date.toUTCString();
			}
			var path = options.path ? '; path=' + (options.path) : '';
			var domain = options.domain ? '; domain=' + (options.domain) : '';
			var secure = options.secure ? '; secure' : '';
			document.cookie = [ name, '=', encodeURIComponent(value), expires,
					path, domain, secure ].join('');
		} else {
			var cookieValue = null;
			if (document.cookie && document.cookie != '') {
				var cookies = document.cookie.split(';');
				for (var i = 0; i < cookies.length; i++) {
					var cookie = $.trim(cookies[i]);
					if (cookie.substring(0, name.length + 1) == (name + '=')) {
						cookieValue = decodeURIComponent(cookie
								.substring(name.length + 1));
						break;
					}
				}
			}
			return cookieValue;
		}
	},
	changeURLStatic: function(name,value){

		    var url = location.href;
    var url2 = "";
    var reg = eval('/([\?|&]' + name + '=)[^&]*/gi');
    value = value.toString().replace(/(^\s*)|(\s*$)/g, "");  //移除首尾空格
    if (!value) {
         url2 = url.replace(reg, '');  //正则替换
    } else {
        if (url.match(reg)) {
             url2 = url.replace(reg, '$1' + value);  //正则替换
        } else {
             url2 = url + (url.indexOf('?') > -1 ? '&' : '?') + name + '=' + value;  //没有参数添加参数
        }
    }
    history.replaceState(null, null, url2);  //替换地址栏

	}
};

//菜单重新定义链接地址
//链接定义
var siteLinks  = {

	"首页":"index.html",
	"药研试剂":"med.html",
	"定制服务":"custom.html",
	"联系我们":"contact.html",
	"体外诊断试剂":"ivd.html",

}

var siteH5Links  = {

	"基本信息":"baseInfo.html",
	"公司资料":"companyInfo.html",
	"我的订单":"myOrder.html",
	"我的购物车":"myCart.html",
	"收货地址":"address.html",
	"发票信息":"invoiceInfo.html",
	"我的收藏":"myCollect.html",
	"绑定微信/绑定企业微信":"bindWx.html",


}


 $("a").each( function(idx,el){

 	var text =$.trim( $(el).text());
 	
 	var link = siteLinks[text] || false;
	var linkH5 = siteH5Links[text] ||false;
 	if(link){
		//menu
 		console.log('a->',text,link);
 		$(el).attr('href',link);

 		//如果是移动版本，则外面还有个li
 		$(el).parent("li").click( function(){
 			window.location.href = link ;
 		})
 	}

	if(linkH5){
		//user-center-mobile
 		console.log('h5 a->',text,linkH5);
		linkH5 = 'invoice_h5_'+ linkH5;
 		$(el).attr('href',linkH5);
 		//如果是移动版本，则外面还有个li
 		$(el).parent("li").click( function(){
 			window.location.href = linkH5 ;
 		})
	}
 });



$("img").each( function(idx,el){

	var img = $(el).attr('src');

	if(img.indexOf('/zhuce.png')>0	){
		console.log('img',img);	
		$(el).css('cursor','pointer').click ( function(){
			window.location.href= 'login.html';
		});
	}
	if(img.indexOf('/car.png')>0	){
		console.log('img',img);	
		$(el).css('cursor','pointer').click ( function(){
			
			if(globalWindowMode!='small'){
				window.location.href='user-center.html';
			}else{
				//mobile
				window.location.href='invoice_h5_baseInfo.html';
			}
		});
	}
	if(img.indexOf('/search.png')>0	){
		console.log('img',img);	
		$(el).css('cursor','pointer').click ( function(){
			window.location.href= 'search-result.html';
		});
	}	
});



$(".addcar").css('cursor','pointer').click( function(){
	
	if(globalWindowMode!='small'){
		window.location.href='user-center.html';
	}else{
		//mobile
		window.location.href='invoice_h5_baseInfo.html';
	}
});


//窗口模式定义， 三种, small ,medium ,lager
var globalWindowMode = 'larger';
function detechWindowMode(){
  var w = window.innerWidth ;

  if(w<= 1024){
      return 'small';
  }else if(w<=1920){
      return 'medium';
  }
  return 'larger';
}

globalWindowMode  = detechWindowMode();


//初始化一下PC版高度
if (globalWindowMode != 'small') {
	$(".scrollDiv").height('100vh');
	$(".scrollDivone").height('92.2vh');
}	


//首页的跳转---移动版
$("div.chakageng").click( function(){

	window.location.href = siteLinks['定制服务'];

});


//结构搜索：.inpuRight h4


